package com.pegatroncorp.motion.resend;

import java.lang.reflect.Constructor;

import com.larry.motion.service.IMotionService;
import com.larry.motion.vo.MessageType;
import com.larry.motion.vo.RegionType;

public class R02Resneder {

	// TODO
	private Integer index = 95;

	// TODO
	private final String region = RegionType.AM.toString();

	private final String messageType = MessageType.CS.toString();

	private IMotionService motionService;

	// TODO
	private String[] orderNrs = new String[] { "EJ460075", "EJ460077" };

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		R02Resneder resende = new R02Resneder();
		resende.resend();
	}

	private void resend() throws Exception {
		this.init();
		for (String orderNr : orderNrs) {
			motionService.genMessageFile(motionService.genFileName(index), orderNr);
			index++;
		}
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	private void init() throws Exception {
		Class className = (Class) MessageType.valueOf(messageType).getClassName();
		Constructor<?> cons = className.getConstructor(String.class);
		motionService = (IMotionService) cons.newInstance(region);
	}
}
